package com.oauth.yahoo.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.oauth.auth.client.beans.MemberClientBean;
import com.oauth.auth.client.rpc.MemberRemoteService;
import com.oauth.auth.client.rpc.MemberRemoteServiceAsync;
import com.oauth.components.client.rpc.OAuthAsnyCallBack;
import com.oauth.components.client.ui.footer.FooterUI;
import com.oauth.components.client.ui.header.HeaderUI;
import com.oauth.yahoo.client.ui.MainPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class YahooEntryPoint implements EntryPoint {

	private final MemberRemoteServiceAsync memberService = GWT.create(MemberRemoteService.class);

	public void onModuleLoad() {
		final HeaderUI header = new HeaderUI();

		memberService.getMember(new OAuthAsnyCallBack<MemberClientBean>() {
			public void onSuccess(MemberClientBean result) {
				header.setUserName(result.getEmail());
			}
		});

		FooterUI footer = new FooterUI();
		DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
		p.addNorth(header, 4);
		p.addSouth(footer, 4);

		MainPanel yahooPanel = new MainPanel();
		yahooPanel.initMainPanel();
		p.add(yahooPanel);
		p.animate(1000);
		header.setLoading(false);
		Window.enableScrolling(true);
		// Attach the LayoutPanel to the RootLayoutPanel. The latter will listen
		// for
		// resize events on the window to ensure that its children are informed
		// of
		// possible size changes.
		RootLayoutPanel rp = RootLayoutPanel.get();
		rp.add(p);
		// RootPanel.get().add(dockPanel);
	}

}
